package com.lwj.liwanjia.presenter;

import com.lwj.liwanjia.bean.BannerBean;
import com.lwj.liwanjia.impl.BannerView;
import com.lwj.liwanjia.model.BannerModel;

import rx.Subscriber;

/**
 * 首页轮播
 */

public class BannerPresenter {
    private BannerView bannerView;
    private BannerModel bannerModel;

    public BannerPresenter(BannerView bannerView) {
        this.bannerView = bannerView;
        bannerModel = new BannerModel();
    }

    public void getBannerData() {
        if (bannerView != null) {
            bannerModel.getBannerData( new Subscriber<BannerBean>() {
                @Override
                public void onCompleted() {

                }

                @Override
                public void onError(Throwable e) {
                    bannerView.showError((Exception) e);
                }

                @Override
                public void onNext(BannerBean bannerBean) {
                    bannerView.getBannerData(bannerBean);
                }
            });
        }
    }
}
